home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / External / CMG / ScoreSubmitter.as < prev    next >
Encoding:
Text File  |  2011-08-19  |  7.4 KB  |  230 lines

  1.  
  2. {
  3.    if(true)
  4.    {
  5.       ScoreSubmitter = ┬º┬ºnewclass(ScoreSubmitter,EventDispatcher);
  6.    }
  7. }
  8.  
  9. package Local.External.CMG
  10. {
  11.    import flash.events.Event;
  12.    import flash.events.EventDispatcher;
  13.    import flash.net.URLLoader;
  14.    import flash.net.URLRequest;
  15.    import flash.net.URLRequestMethod;
  16.    import flash.net.URLVariables;
  17.    
  18.    public class ScoreSubmitter extends EventDispatcher
  19.    {
  20.       
  21.       public static const RETURNCODE_SUCCESS:* = 1;
  22.       
  23.       public static var gameVersion:String = "";
  24.       
  25.       public static var gameValidationCode:String = "";
  26.       
  27.       public static const RETURNCODE_REJECTED:* = 2;
  28.       
  29.       public static const RETURNCODE_INTERNALERROR:* = 5;
  30.       
  31.       public static const URL_SUBMITSCORE:* = "http://scores.crazymonkeygames.com/hs/regscores2.php";
  32.       
  33.       public static const URL_UPDATEGAME:* = "http://scores.crazymonkeygames.com/hs/pleaseupdate.php";
  34.       
  35.       public static var gameId:uint = 0;
  36.       
  37.       public static const SCORE_RESPONSE:String = "score_response";
  38.       
  39.       public static const RETURNCODE_WORKING:* = 0;
  40.       
  41.       public static const RETURNCODE_WRONGVERSION:* = 3;
  42.       
  43.       public static const URL_VIEWSCORES:* = "http://scores.crazymonkeygames.com/hs/listscores.php";
  44.       
  45.       public static const RETURNCODE_NETWORKERROR:* = 4;
  46.       
  47.       {
  48.          if(true)
  49.          {
  50.             gameId = 0;
  51.             if(true)
  52.             {
  53.                gameVersion = "";
  54.                if(true)
  55.                {
  56.                   gameValidationCode = "";
  57.                   if(true)
  58.                   {
  59.                      SCORE_RESPONSE = "score_response";
  60.                      if(true)
  61.                      {
  62.                         RETURNCODE_WORKING = 0;
  63.                         if(true)
  64.                         {
  65.                            RETURNCODE_SUCCESS = 1;
  66.                            if(true)
  67.                            {
  68.                               RETURNCODE_REJECTED = 2;
  69.                            }
  70.                            RETURNCODE_WRONGVERSION = 3;
  71.                         }
  72.                         RETURNCODE_NETWORKERROR = 4;
  73.                      }
  74.                      RETURNCODE_INTERNALERROR = 5;
  75.                   }
  76.                   URL_VIEWSCORES = "http://scores.crazymonkeygames.com/hs/listscores.php";
  77.                }
  78.                URL_SUBMITSCORE = "http://scores.crazymonkeygames.com/hs/regscores2.php";
  79.             }
  80.             URL_UPDATEGAME = "http://scores.crazymonkeygames.com/hs/pleaseupdate.php";
  81.          }
  82.       }
  83.       
  84.       private var m_UrlLoader:URLLoader = null;
  85.       
  86.       public function ScoreSubmitter()
  87.       {
  88.          if(true)
  89.          {
  90.             m_UrlLoader = null;
  91.             super();
  92.          }
  93.       }
  94.       
  95.       public static function loadHighScorePage() : void
  96.       {
  97.          Utilities.goToUrl(URL_VIEWSCORES + "?id=" + gameId);
  98.       }
  99.       
  100.       public static function loadUpdatePage() : *
  101.       {
  102.          Utilities.goToUrl(URL_VIEWSCORES + "?id=" + gameId);
  103.       }
  104.       
  105.       private function onIoError(param1:Event) : *
  106.       {
  107.          dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_NETWORKERROR));
  108.       }
  109.       
  110.       public function submitScore(param1:String, param2:Number, param3:String = null) : void
  111.       {
  112.          var _loc4_:* = undefined;
  113.          var _loc5_:URLRequest = null;
  114.          ┬º┬ºpush(Utilities.trim(param1));
  115.          if(true)
  116.          {
  117.             ┬º┬ºpush(┬º┬ºpop());
  118.             if(true)
  119.             {
  120.                param1 = ┬º┬ºpop();
  121.                gameVersion = Utilities.trim(gameVersion);
  122.                ┬º┬ºpush(param3);
  123.                if(true)
  124.                {
  125.                   if(┬º┬ºpop() == null)
  126.                   {
  127.                      param3 = "";
  128.                   }
  129.                   else
  130.                   {
  131.                      addr41:
  132.                      param3 = Utilities.trim(param3);
  133.                   }
  134.                   gameValidationCode = Utilities.trim(gameValidationCode);
  135.                   ┬º┬ºpush(gameId < 1);
  136.                   ┬º┬ºpush(gameId < 1);
  137.                   if(true)
  138.                   {
  139.                      if(!┬º┬ºpop())
  140.                      {
  141.                         ┬º┬ºpop();
  142.                         addr56:
  143.                         ┬º┬ºpush(gameVersion == "");
  144.                      }
  145.                      ┬º┬ºpush(┬º┬ºpop());
  146.                   }
  147.                   if(!┬º┬ºpop())
  148.                   {
  149.                      ┬º┬ºpop();
  150.                      addr62:
  151.                      ┬º┬ºpush(gameValidationCode == "");
  152.                   }
  153.                   if(┬º┬ºpop())
  154.                   {
  155.                      dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_REJECTED));
  156.                      return;
  157.                   }
  158.                   dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_WORKING));
  159.                   (_loc4_ = new URLVariables()).name = param1;
  160.                   _loc4_.score = param2;
  161.                   _loc4_.gameId = gameId;
  162.                   _loc4_.gameVersion = gameVersion;
  163.                   _loc4_.special = param3;
  164.                   _loc4_.key = MD5.encrypt(param1 + "|" + param2 + "|" + gameId + "|" + param3 + "|" + gameValidationCode);
  165.                   (_loc5_ = new URLRequest(URL_SUBMITSCORE)).method = URLRequestMethod.POST;
  166.                   if(true)
  167.                   {
  168.                      _loc5_.data = _loc4_;
  169.                      if(true)
  170.                      {
  171.                         m_UrlLoader = new URLLoader();
  172.                         if(true)
  173.                         {
  174.                            m_UrlLoader.addEventListener("complete",onComplete);
  175.                         }
  176.                         m_UrlLoader.addEventListener("ioError",onIoError);
  177.                      }
  178.                      m_UrlLoader.load(_loc5_);
  179.                   }
  180.                   return;
  181.                }
  182.                ┬º┬ºgoto(addr41);
  183.             }
  184.             ┬º┬ºgoto(addr56);
  185.          }
  186.          ┬º┬ºgoto(addr62);
  187.       }
  188.       
  189.       private function onComplete(param1:Event) : void
  190.       {
  191.          var _loc2_:URLVariables = null;
  192.          var _loc3_:* = undefined;
  193.          _loc2_ = new URLVariables(m_UrlLoader.data.replace("&",""));
  194.          _loc3_ = Utilities.trim(_loc2_.ok);
  195.          if(true)
  196.          {
  197.             if(_loc3_ == 1)
  198.             {
  199.                if(true)
  200.                {
  201.                   dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_SUCCESS));
  202.                   if(true)
  203.                   {
  204.                      ┬º┬ºgoto(addr88);
  205.                   }
  206.                   else
  207.                   {
  208.                      addr68:
  209.                      dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_WRONGVERSION));
  210.                   }
  211.                }
  212.             }
  213.             else if(_loc3_ == 0)
  214.             {
  215.                if(true)
  216.                {
  217.                   dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_REJECTED));
  218.                }
  219.             }
  220.             else if(_loc3_ != 2)
  221.             {
  222.                dispatchEvent(new ServerResponseEvent(SCORE_RESPONSE,RETURNCODE_INTERNALERROR));
  223.             }
  224.             ┬º┬ºgoto(addr88);
  225.          }
  226.          addr88:
  227.       }
  228.    }
  229. }
  230.